knitr::opts_chunk$set(echo = TRUE, warning = FALSE, message = FALSE)
library(spatstat)
library(maptools)
# library(sp)
library(raster) ### BEFORE tidyverse! b/c select()
library(tidyverse)
library(here)
library(sf)
library(tmap)
library(gstat)
library(stars)
library(janitor)
Sky News: California Oil Spill 2021
This report will carry out a spatial analysis using tmap to create an interactive map showing the location of soil spill events in california using the CA DFW Oil Spill Incident Tracking database.
This report will also produce the creation of a finalized static choropleth map using ggplot in which the fill color for each county depends on the count of inland oil spill events by county for the 2008 oil spill data.
Data Source: The data used for analysis is from the CA DFW Oil Spill Incident Tracking dataset. The database system is designed to provide OSPR with quantified statistical data on oil spill response by OSPR field responders. The OSPR Incident Tracking Database System project was initiated to provide OSPR with oil spill incident data for statistical evaluation and justification for program planning, drills and exercise training and development, legislative analysis, budget preparation, to inform and educate the public and analyze OSPR’s overall spill preparedness and response performance. An “incident”, for purposes of this database, is “a discharge or threatened discharge of petroleum or other deleterious material into the waters of the state.”
Data can also be downloaded from the State of California Geoportal
# Reading in the data
oil <- read_sf(here("data", "Oil_Spill_Incident_Tracking_[ds394]", "Oil_Spill_Incident_Tracking_[ds394].shp"))
# Check the projection
#st_crs(oil)
# Read in the CA county data (TIGER shapefile):
ca_counties_sf <- read_sf(here("data/ca_counties"), layer = "CA_Counties_TIGER2016") %>%
janitor::clean_names() %>%
select(name)
# Check the projection
#st_crs(ca_counties_sf)
#testing a plot to make sure the plot runs
#ggplot() +
# geom_sf(data = ca_counties_sf) +
#geom_sf(data = oil)
# TSetting Tmap to plot:
tmap_mode("view")
#Mapping with the oil data and the county data
tm_shape(ca_counties_sf) +
tm_polygons(alpha = 0) +
tm_shape(oil) +
tm_dots(col = "navyblue") +
tm_layout(title= 'Oil Spills in California from the CA DFW Oil Spill Incident Tracking')